package com.ds.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean;

import javax.validation.Validation;

/**
 * @class: ValidationConfig
 * @description:
 * @author: fs
 * @create: 2024/4/9 10:55
 **/
@Configuration
public class ValidationConfig {
    @Bean
    public LocalValidatorFactoryBean validatorFactoryBean() {
        LocalValidatorFactoryBean factoryBean = new LocalValidatorFactoryBean();
        javax.validation.Configuration<?> configure = Validation.byDefaultProvider().configure();
        factoryBean.setMessageInterpolator(new CustomMessageInterpolator(configure.getDefaultMessageInterpolator()));
        return factoryBean;
    }
}
